//
//  RecommendViewModel.swift
//  SLQuickReader
//
//  Created by ALin on 2017/8/10.
//  Copyright © 2017年 ALin. All rights reserved.
//

import UIKit

class RecommendViewModel: BaseViewModel, BaseView {
    private weak var tableView: UITableView!
    fileprivate func bind2fetchRecommends(){
        BookstoreProvider.request(.recommend).parse2Books().bind(to: tableView.rx.items(cellIdentifier: "RecommendCell", cellType: RecommendCell.self)){ row, element, cell in
            let model = RecommendCellModel()
            model.recommendBook = element
            model.bind(to: cell)
        }.disposed(by: disposBag)
    }
    
    func bind(to view: UIView...) {
        guard let tab = view.first as? UITableView else {
            return
        }
        tableView = tab
        bind2fetchRecommends()
    }
}
